home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 003-desktop.lzm / usr / bin / kdeeject < prev    next >
Encoding:
Text File  |  2006-10-01  |  1.1 KB  |  41 lines

  1. #!/bin/sh
  2. # Script used by kdesktop to eject a removable media (CDROM/Tape/SCSI/Floppy)
  3. # Relies on the 'eject' program, 'cdcontrol' on *BSD
  4. #
  5. # Copyright GPL v2 by David Faure <david@mandrakesoft.com>
  6. #
  7. if test $# -ge 1 -a "$1" != "--help"; then
  8.   quiet=0
  9.   if test "$1" = "-q"; then
  10.     quiet=1
  11.     shift
  12.   fi
  13.   # Checking for stuff in the PATH is ugly with sh.
  14.   # I guess this is the reason for making this a kde app...
  15.   OS=`uname -s`
  16.   case "$OS" in
  17.     OpenBSD)
  18.       cdio -f $1 eject >/dev/null 2>&1
  19.       ;;
  20.     *BSD)
  21.       dev=`echo $1 | sed -E -e 's#/dev/##' -e 's/([0-9])./\1/'`
  22.       cdcontrol -f $dev eject >/dev/null 2>&1
  23.       ;;
  24.     *)
  25.       # Warning, it has to be either eject 2.0.x or >=2.1.5
  26.       # Otherwise it doesn't work as expected (it requires a
  27.       # fstab entry for no reason).
  28.       eject $1 >/dev/null 2>&1
  29.       ;;
  30.   esac
  31.   if test $? -eq 0; then
  32.     dcop kdesktop default refreshIcons
  33.     exit 0
  34.   elif test $quiet -eq 0; then
  35.     kdialog --title "KDE Eject" --error "Eject $1 failed!"
  36.   fi
  37. else
  38.   kdialog --title "KDE Eject" --msgbox "Usage: $0 <name> where name is a device or a mountpoint."
  39. fi
  40. exit 1
  41.